/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package gameserver;

import java.net.MalformedURLException;
import java.rmi.Naming;
import java.rmi.RemoteException;
import registration.Registration;
import registration.UnoGameRegistration;

/**
 *
 * @author marco
 */
public class GameServer {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        String rmi_uri = null;
        Registration registration_server = null;

        if (args.length != 2) {
            System.err.println("Numero parametri passati errato, usare:\njava gameserver.GameServer <ip-rmiregistry> <port-rmiregistry>");
            System.exit(1);
        }

        try {
            rmi_uri = "rmi://" + args[0] + ":" + args[1] + "/" + "UnoGameRegistration";
            registration_server = new UnoGameRegistration();
            Naming.rebind(rmi_uri, registration_server);
            System.out.println("Server pubblicato " + rmi_uri);
        } catch (MalformedURLException ex) {
            System.err.println("Indirizzo " + rmi_uri + " errato per pubblicre il servver");
            ex.printStackTrace();
        } catch (RemoteException ex) {
            System.err.println("Erore nella creazione del server");
            ex.printStackTrace();
        }
    }
}
